package com.itheima.app.interceptor;

import com.itheima.domain.db.User;
import org.apache.tomcat.jni.Local;

/**
 * 操作user的线程绑定
 */
public class UserHolder {
    private static ThreadLocal<User> local = new ThreadLocal<User>();

    /**
     * 放入线程
     */
    public static void set(User user){
        local.set(user);
    }
    /**
     * 放入线程
     */
    public static User get(){
        return local.get();
    }

    /**
     * 放入线程
     */
    public static void remove(){
        local.remove();
    }

    public static Long getId(){
         return get().getId();
    }
}
